Skip to content

fix(llmobs): format AI SDK rich tool results#9399

Open
BridgeAR wants to merge 9 commits into
masterfrom
BridgeAR/2026-07-16-fix-ai-tool-results
Open

fix(llmobs): format AI SDK rich tool results#9399
BridgeAR wants to merge 9 commits into
masterfrom
BridgeAR/2026-07-16-fix-ai-tool-results

Conversation

@BridgeAR

Copy link
Copy Markdown
Member

Summary

AI SDK multipart and error tool outputs were treated as unparsable. This preserves text, emits metadata-free summaries for rich file and image parts, and keeps malformed or circular telemetry inputs from throwing.

Fixes: #9395

@dd-octo-sts

dd-octo-sts Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 7.48 MB
Deduped: 8.14 MB
No deduping: 8.14 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.3.2 | 124.41 kB | 440.65 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | dc-polyfill | 0.1.11 | 25.74 kB | 25.74 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@pr-commenter

pr-commenter Bot commented Jul 16, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-07-23 15:30:38

Comparing candidate commit 8c60bfb in PR branch BridgeAR/2026-07-16-fix-ai-tool-results with baseline commit 199f69c in branch master.

📊 Benchmarking dashboard

Found 0 performance improvements and 0 performance regressions! Performance is the same for 2310 metrics, 48 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

Unstable benchmarks

These benchmarks have a confidence interval too wide to call a change; treat them as noise rather than signal.

scenario:appsec-appsec-enabled-24

  • unstable execution_time [-201.457ms; +209.273ms] or [-7.585%; +7.879%]

scenario:appsec-appsec-enabled-26

  • unstable execution_time [-242.962ms; +236.452ms] or [-9.518%; +9.263%]

scenario:appsec-appsec-enabled-with-attacks-24

  • unstable execution_time [-123.005ms; +188.886ms] or [-4.014%; +6.163%]

scenario:appsec-appsec-enabled-with-attacks-26

  • unstable execution_time [-198.844ms; +182.481ms] or [-6.841%; +6.278%]

scenario:appsec-control-20

  • unstable execution_time [-115.756ms; +128.718ms] or [-7.114%; +7.911%]

scenario:appsec-control-24

  • unstable execution_time [-95.407ms; +126.412ms] or [-7.695%; +10.196%]

scenario:appsec-control-26

  • unstable execution_time [-123.946ms; +126.540ms] or [-9.999%; +10.208%]

scenario:appsec-iast-no-vulnerability-iast-enabled-always-active-20

  • unstable execution_time [-10.289ms; +22.433ms] or [-4.004%; +8.731%]

scenario:appsec-iast-no-vulnerability-iast-enabled-default-config-20

  • unstable execution_time [-13824.602µs; +13914.492µs] or [-5.477%; +5.513%]

scenario:appsec-iast-with-vulnerability-control-20

  • unstable execution_time [-30753.298µs; +30326.318µs] or [-5.611%; +5.533%]

scenario:child_process-file-args-24

  • unstable execution_time [-28503.660µs; +30113.993µs] or [-5.933%; +6.268%]

scenario:debugger-line-probe-with-snapshot-minimal-24

  • unstable cpu_user_time [-1785.854ms; +539.196ms] or [-21.495%; +6.490%]
  • unstable execution_time [-1794.158ms; +557.386ms] or [-19.886%; +6.178%]
  • unstable instructions [-15.0G instructions; +4.8G instructions] or [-22.165%; +7.147%]
  • unstable throughput [-146.710op/s; +481.774op/s] or [-4.018%; +13.194%]

scenario:debugger-line-probe-with-snapshot-minimal-26

  • unstable cpu_user_time [-3648.312ms; +3681.337ms] or [-35.446%; +35.767%]
  • unstable execution_time [-3685.305ms; +3734.442ms] or [-33.394%; +33.839%]
  • unstable instructions [-32420.7M instructions; +32631.3M instructions] or [-37.526%; +37.769%]
  • unstable max_rss_usage [-10627.992KB; +12144.792KB] or [-6.600%; +7.542%]
  • unstable throughput [-740.236op/s; +710.470op/s] or [-23.965%; +23.001%]

scenario:debugger-line-probe-without-snapshot-24

  • unstable cpu_user_time [-1967.315ms; +3145.826ms] or [-23.714%; +37.920%]
  • unstable execution_time [-1982.980ms; +3202.139ms] or [-22.044%; +35.596%]
  • unstable instructions [-17.1G instructions; +27.2G instructions] or [-25.300%; +40.169%]
  • unstable max_rss_usage [-8.505MB; +13.278MB] or [-5.413%; +8.451%]
  • unstable throughput [-854.595op/s; +524.496op/s] or [-23.341%; +14.325%]

scenario:debugger-line-probe-without-snapshot-26

  • unstable cpu_user_time [-4638.520ms; +3111.624ms] or [-41.907%; +28.112%]
  • unstable execution_time [-4682.193ms; +3173.617ms] or [-39.674%; +26.892%]
  • unstable instructions [-41.1G instructions; +27.2G instructions] or [-44.008%; +29.104%]
  • unstable max_rss_usage [-14.748MB; +10.796MB] or [-9.044%; +6.620%]
  • unstable throughput [-626.445op/s; +909.024op/s] or [-21.294%; +30.900%]

scenario:dogstatsd-with-tags-20

  • unstable cpu_user_time [-304.481ms; +382.427ms] or [-6.390%; +8.025%]
  • unstable execution_time [-304.782ms; +384.668ms] or [-6.299%; +7.949%]
  • unstable throughput [-136045.956op/s; +109367.595op/s] or [-7.843%; +6.305%]

scenario:llmobs-span-processor-agent-26

  • unstable execution_time [-277.155ms; +167.932ms] or [-6.282%; +3.806%]
  • unstable throughput [-8714.869op/s; +15569.808op/s] or [-4.021%; +7.185%]

scenario:plugin-claude-agent-sdk-compact-stream-scan-26

  • unstable cpu_usage_percentage [-7.066%; +2.987%]

scenario:plugin-graphql-long-with-depth-and-collapse-off-20

  • unstable max_rss_usage [-19.219MB; +22.074MB] or [-4.932%; +5.665%]

scenario:plugin-graphql-long-with-depth-off-26

  • unstable max_rss_usage [-36.086MB; +18.245MB] or [-16.572%; +8.379%]

scenario:plugin-graphql-long-with-depth-on-max-20

  • unstable cpu_user_time [-649.766ms; +610.192ms] or [-5.631%; +5.288%]
  • unstable execution_time [-662.644ms; +627.818ms] or [-5.627%; +5.331%]
  • unstable throughput [-3.655op/s; +3.912op/s] or [-5.347%; +5.723%]

scenario:plugin-pg-service-20

  • unstable cpu_usage_percentage [-7.900%; +4.844%]
  • unstable execution_time [-115.518ms; +182.627ms] or [-7.079%; +11.192%]
  • unstable throughput [-302912.293op/s; +192127.184op/s] or [-8.151%; +5.170%]

scenario:plugin-pg-service-26

  • unstable cpu_usage_percentage [-6.585%; +3.553%]
  • unstable execution_time [-47.935ms; +68.352ms] or [-5.280%; +7.529%]
  • unstable throughput [-426151.115op/s; +305036.685op/s] or [-6.365%; +4.556%]

scenario:test-optimization-large-suite-20

  • unstable max_rss_usage [-5575.461KB; +5399.794KB] or [-6.877%; +6.660%]

@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Jul 16, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 98.44% (-0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 8c60bfb | Docs | Datadog PR Page | Give us feedback!

@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.44%. Comparing base (199f69c) to head (8c60bfb).
⚠️ Report is 14 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9399      +/-   ##
==========================================
- Coverage   98.45%   98.44%   -0.01%     
==========================================
  Files         943      941       -2     
  Lines      127336   127048     -288     
  Branches    10824    11202     +378     
==========================================
- Hits       125365   125078     -287     
+ Misses       1971     1970       -1     
Flag Coverage Δ
aiguard 57.50% <ø> (-0.41%) ⬇️
aiguard-integration 56.30% <36.53%> (+0.09%) ⬆️
apm-bucket-0 57.75% <ø> (-0.03%) ⬇️
apm-bucket-1 64.04% <ø> (-0.03%) ⬇️
apm-bucket-2 62.81% <ø> (-0.03%) ⬇️
apm-bucket-3 60.17% <ø> (-0.03%) ⬇️
apm-capabilities-tracing 64.59% <36.53%> (+0.09%) ⬆️
apm-integrations-aerospike 56.75% <ø> (-0.03%) ⬇️
apm-integrations-confluentinc-kafka-javascript 61.68% <ø> (-0.03%) ⬇️
apm-integrations-couchbase 57.19% <ø> (-0.03%) ⬇️
apm-integrations-http 62.82% <ø> (-0.03%) ⬇️
apm-integrations-kafkajs 62.24% <ø> (-0.03%) ⬇️
apm-integrations-next 59.29% <ø> (-0.03%) ⬇️
apm-integrations-prisma 58.76% <ø> (-0.03%) ⬇️
appsec 72.94% <ø> (-0.07%) ⬇️
appsec-express_fastify_graphql 70.44% <ø> (-0.02%) ⬇️
appsec-integration 51.51% <ø> (+0.08%) ⬆️
appsec-kafka_ldapjs_lodash 64.02% <ø> (-0.03%) ⬇️
appsec-mongodb-core_mongoose_mysql 67.74% <ø> (-0.02%) ⬇️
appsec-next 57.61% <ø> (+<0.01%) ⬆️
appsec-node-serialize_passport_postgres 67.41% <ø> (-0.06%) ⬇️
appsec-sourcing_stripe_template 65.76% <ø> (-0.02%) ⬇️
debugger 64.94% <ø> (-0.03%) ⬇️
instrumentations-bucket-0 51.84% <ø> (+0.11%) ⬆️
instrumentations-bucket-1 60.34% <ø> (+0.03%) ⬆️
instrumentations-bucket-10 62.14% <ø> (+0.26%) ⬆️
instrumentations-bucket-11 51.75% <ø> (-5.05%) ⬇️
instrumentations-bucket-12 52.32% <ø> (+0.22%) ⬆️
instrumentations-bucket-13 51.86% <ø> (-0.26%) ⬇️
instrumentations-bucket-2 53.75% <ø> (+0.33%) ⬆️
instrumentations-bucket-3 59.34% <ø> (+5.62%) ⬆️
instrumentations-bucket-4 52.41% <ø> (-6.90%) ⬇️
instrumentations-bucket-5 57.65% <ø> (+7.52%) ⬆️
instrumentations-bucket-6 60.86% <ø> (-0.17%) ⬇️
instrumentations-bucket-7 58.52% <ø> (+0.05%) ⬆️
instrumentations-bucket-8 59.67% <ø> (+0.13%) ⬆️
instrumentations-bucket-9 61.66% <ø> (+9.55%) ⬆️
instrumentations-instrumentation-couchbase 51.15% <ø> (-0.03%) ⬇️
instrumentations-instrumentation-zlib ?
instrumentations-integration-esbuild 34.25% <ø> (+0.11%) ⬆️
llmobs-ai_anthropic_bedrock 62.93% <100.00%> (+0.03%) ⬆️
llmobs-bucket-1 61.66% <ø> (+0.01%) ⬆️
llmobs-openai 62.79% <ø> (-0.03%) ⬇️
llmobs-sdk 66.25% <ø> (-0.03%) ⬇️
llmobs-vertex-ai 59.29% <ø> (-0.04%) ⬇️
master-coverage 98.44% <100.00%> (?)
openfeature 56.21% <ø> (ø)
openfeature-unit 53.51% <ø> (-0.03%) ⬇️
platform-core_esbuild_instrumentations-misc 40.62% <ø> (+0.14%) ⬆️
platform-integration 61.52% <ø> (ø)
platform-shimmer_unit-guardrails_webpack 39.24% <ø> (+0.08%) ⬆️
plugins-bucket-0 57.15% <ø> (-0.03%) ⬇️
plugins-bucket-1 54.46% <ø> (ø)
plugins-bucket-11 62.38% <ø> (-0.03%) ⬇️
plugins-bucket-18 62.07% <ø> (-0.03%) ⬇️
plugins-bucket-19 60.17% <ø> (-0.03%) ⬇️
plugins-bucket-20 62.17% <ø> (-0.03%) ⬇️
plugins-bucket-4 58.69% <ø> (-0.03%) ⬇️
plugins-bullmq_cassandra_cookie 61.86% <ø> (-0.03%) ⬇️
plugins-cookie-parser_crypto_dd-trace-api 56.85% <ø> (-0.03%) ⬇️
plugins-fetch_fs_generic-pool 58.89% <ø> (-0.03%) ⬇️
plugins-google-cloud-pubsub_grpc_handlebars 64.80% <ø> (-0.03%) ⬇️
plugins-hapi_hono_ioredis 60.34% <ø> (-0.03%) ⬇️
plugins-jest_knex_langgraph 55.71% <ø> (-0.03%) ⬇️
plugins-ldapjs_light-my-request_limitd-client 58.62% <ø> (-0.03%) ⬇️
plugins-lodash_mariadb_memcached 58.12% <ø> (-0.03%) ⬇️
plugins-moleculer_mongodb_mongodb-core 62.03% <ø> (-0.03%) ⬇️
plugins-mongoose_multer_mysql 59.13% <ø> (-0.03%) ⬇️
plugins-mysql2_nats_node-serialize 60.83% <ø> (-0.03%) ⬇️
plugins-opensearch_passport-http_pino 59.66% <ø> (-0.03%) ⬇️
plugins-postgres_process_pug 58.39% <ø> (-0.03%) ⬇️
plugins-redis_router_sequelize 62.16% <ø> (-0.03%) ⬇️
plugins-test-and-upstream-rhea_undici_url 61.74% <ø> (-0.03%) ⬇️
plugins-valkey_vm_winston 58.13% <ø> (-0.03%) ⬇️
plugins-ws 59.72% <ø> (-0.04%) ⬇️
profiling 62.25% <ø> (-0.03%) ⬇️
serverless-aws-sdk-aws-sdk 55.15% <ø> (-0.05%) ⬇️
serverless-aws-sdk-bedrockruntime 54.86% <ø> (-0.03%) ⬇️
serverless-aws-sdk-client 56.54% <ø> (-0.03%) ⬇️
serverless-aws-sdk-dynamodb 55.77% <ø> (-0.04%) ⬇️
serverless-aws-sdk-eventbridge 49.48% <ø> (-0.03%) ⬇️
serverless-aws-sdk-kinesis 59.45% <ø> (-0.03%) ⬇️
serverless-aws-sdk-lambda 57.50% <ø> (-0.03%) ⬇️
serverless-aws-sdk-s3 55.71% <ø> (-0.03%) ⬇️
serverless-aws-sdk-serverless-peer-service 59.85% <ø> (-0.03%) ⬇️
serverless-aws-sdk-sns 60.24% <ø> (-0.03%) ⬇️
serverless-aws-sdk-sqs 60.68% <ø> (-0.03%) ⬇️
serverless-aws-sdk-stepfunctions 55.69% <ø> (-0.03%) ⬇️
serverless-aws-sdk-util 51.59% <ø> (-0.03%) ⬇️
serverless-bucket-0 54.35% <ø> (-0.01%) ⬇️
serverless-bucket-1 59.37% <ø> (-0.03%) ⬇️
test-optimization-cucumber 72.07% <ø> (+0.13%) ⬆️
test-optimization-cypress 65.89% <ø> (+0.14%) ⬆️
test-optimization-jest 73.32% <ø> (+<0.01%) ⬆️
test-optimization-mocha 73.57% <ø> (+0.10%) ⬆️
test-optimization-playwright-playwright-atr 60.48% <ø> (+0.05%) ⬆️
test-optimization-playwright-playwright-efd 60.66% <ø> (+0.06%) ⬆️
test-optimization-playwright-playwright-final-status 60.63% <ø> (+0.05%) ⬆️
test-optimization-playwright-playwright-impacted-tests 60.44% <ø> (+0.29%) ⬆️
test-optimization-playwright-playwright-reporting 61.66% <ø> (-0.04%) ⬇️
test-optimization-playwright-playwright-test-management 61.17% <ø> (-0.05%) ⬇️
test-optimization-playwright-playwright-test-span 60.58% <ø> (-0.02%) ⬇️
test-optimization-selenium 60.14% <ø> (-0.08%) ⬇️
test-optimization-testopt 58.58% <ø> (+0.17%) ⬆️
test-optimization-vitest 70.36% <ø> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread packages/dd-trace/src/llmobs/plugins/ai/util.js Outdated
Comment thread packages/dd-trace/test/llmobs/plugins/ai/util.spec.js Outdated
@BridgeAR
BridgeAR force-pushed the BridgeAR/2026-07-16-fix-ai-tool-results branch from aaa217b to aab8927 Compare July 20, 2026 18:14
BridgeAR added 3 commits July 21, 2026 03:17
AI SDK tool outputs can contain multipart content and error variants. Preserve text, replace file and image payloads with safe summaries, and fall back without throwing on malformed values.

Fixes: #9395
AI SDK 7 emits generic file and provider-reference parts that were reported as unparsable. Model the supported output shapes locally and exercise content outputs through both telemetry paths so SDK shape changes fail on the user path.
Adding toModelOutput changed the second provider request without a matching cassette, so every AI SDK v5-v7 matrix forwarded to OpenAI with the fake key. Keep the recorded workflow payload stable while formatter coverage pins the rich result shapes and schema precedence.
@BridgeAR
BridgeAR force-pushed the BridgeAR/2026-07-16-fix-ai-tool-results branch from aab8927 to d91d6d8 Compare July 21, 2026 01:19
Direct utility tests pinned hand-built shapes and missed the SDK transformations that feed LLMObs. Drive supported results through generateText across all model protocol versions, while keeping direct safety assertions only for values the SDK rejects before model invocation.
@BridgeAR
BridgeAR marked this pull request as ready for review July 21, 2026 11:04
@BridgeAR
BridgeAR requested a review from a team as a code owner July 21, 2026 11:04
Comment thread packages/dd-trace/test/llmobs/plugins/ai/tool-result-model.js Outdated
Comment thread packages/dd-trace/src/llmobs/plugins/ai/util.js Outdated
sabrenner
sabrenner previously approved these changes Jul 23, 2026
Comment thread packages/dd-trace/src/llmobs/plugins/ai/util.js Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LLMObs Vercel AI integration cannot parse content tool results

2 participants